Skip to content

PVS and Clang-tidy modify #1077

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Dec 4, 2019

Conversation

dota17
Copy link
Member

@dota17 dota17 commented Nov 1, 2019

Fix some remaining lower priority warnings in issue #747:

  • V127. An overflow of the 32-bit variable is possible inside a long cycle which utilizes a memsize-type loop counter. (int --> size_t)

Because that PVS Studio report is old, I use clang-tidy tools to scan jsoncpp recently like #1033 #1048 and find two warnings:

warning: use auto when initializing with a cast to avoid duplicating the type name [modernize-use-auto]
warning: use 'using' instead of 'typedef' [modernize-use-using]

@coveralls
Copy link

coveralls commented Nov 1, 2019

Coverage Status

Coverage increased (+0.003%) to 92.138% when pulling 7be1cef on dota17:PVSandClangtidyModify into a0bd9ad on open-source-parsers:master.

@dota17 dota17 requested review from baylesj, BillyDonahue and cdunn2001 and removed request for baylesj and BillyDonahue November 1, 2019 09:20
@cdunn2001
Copy link
Contributor

These are all good changes, but I'd really rather see the test-coverage go up before we worry about cosmetic improvements.

@dota17
Copy link
Member Author

dota17 commented Nov 13, 2019

These are all good changes, but I'd really rather see the test-coverage go up before we worry about cosmetic improvements.

Hi @cdunn2001
Currently, what's our goal of the test-coverage? Is there a minimal threshold? At the present, we have gone up to 90%+ coverage on the whole.

Since the latest version is only a pre-release version, and some users feedback that there is a little problem with it, so will we need to release a stable version after the coverge reach the goal?

@dota17 dota17 force-pushed the PVSandClangtidyModify branch from c449ba6 to 3935acd Compare November 14, 2019 02:25
@@ -56,7 +56,7 @@ static Json::String readInputTestFile(const char* path) {
return "";
fseek(file, 0, SEEK_END);
long const size = ftell(file);
size_t const usize = static_cast<unsigned long>(size);
const auto usize = static_cast<size_t>(size);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All this buggy fuss.
Meanwhile this whole function is conceptually 4 easy lines. :)

static Json::String readInputTestFile(const char* path) {
    std::ifstream in(path, in.binary);
    std::stringstream os;
    os << in.rdbuf();
    return Json::String(os.str());
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's great! but this sould be in another PR.

int delta = int(value_.map_->size() - other.value_.map_->size());
if (delta)
return delta < 0;
auto thisSize = value_.map_->size();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could try doing it an easier way.

// order by map size, then by map contents.
auto tieFields = [](const Value& v) { return std::tie(v.map_->size(), *v.map_); };
return tieFields(*this) < tieFields(other);

@cdunn2001
Copy link
Contributor

Currently, what's our goal of the test-coverage? Is there a minimal threshold? At the present, we have gone up to 90%+ coverage on the whole.

Well, I thought someone said the jsontestrunner used the old Reader, not the new CharReader. If that's true, we are missing a lot of behavioral coverage. But maybe I misunderstood that.

@dota17 dota17 requested a review from BillyDonahue December 3, 2019 11:24
@dota17 dota17 merged commit 2983f5a into open-source-parsers:master Dec 4, 2019
@dota17 dota17 deleted the PVSandClangtidyModify branch January 13, 2020 08:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants